package org.msfj.admin.feign;

import org.msfj.admin.vo.UserVo;
import org.msfj.authority.client.configuration.ClientAutoConfiguration;
import org.msfj.common.model.CommonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 获取用户信息的远程接口
 */
@FeignClient(value = "admin-service", configuration = {ClientAutoConfiguration.class})
public interface UserApi {
    /**
     * 根据用户id获取用户信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/api/user/getById")
    CommonResult<UserVo> getById(@RequestParam("id") String id);

    /**
     * 根据用户id查询用户姓名
     *
     * @param id
     * @return
     */
    @RequestMapping("/api/user/getNameById")
    CommonResult<String> getNameById(@RequestParam("id") String id);

    /**
     * 根据id列表查询多个用户的信息
     *
     * @param ids
     * @return
     */
    @RequestMapping("/api/user/findByIds")
    CommonResult<List<UserVo>> getByIds(@RequestParam("ids") List<String> ids);

    /**
     * 查询所有用户
     *
     * @return
     */
    @RequestMapping("/api/user/all")
    CommonResult<List<UserVo>> getAllUser();

    /**
     * 查询所有用户
     *
     * @return
     */
    @RequestMapping(value = "/api/user/allByUser",method = RequestMethod.POST)
    CommonResult<List<UserVo>> getAllUser(@RequestBody UserVo userVo);

    /**
     * 更新用户密码
     *
     * @return
     */
    @RequestMapping(value = "/api/user/updateNewPwd", method = RequestMethod.POST)
    CommonResult updateNewPwd(@RequestBody UserVo user);

    /**
     * 根据用户id列表查询用户名称
     *
     * @param ids
     * @return
     */
    @RequestMapping("/api/user/findIdNameMapByIds")
    CommonResult<Map<Long, String>> getUserNames(@RequestParam(value = "ids",required = false) List<String> ids);

    /**
     * 根据登录用户名查找用户
     *
     * @param account
     * @return
     */
    @GetMapping("/api/user/getByAccount")
    CommonResult<UserVo> getByAccount(@RequestParam("account") String account);
}
